<?php
include_once("../modules/checkA.php");
include_once("../../config.php"); 
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'rental'");
?>


<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];
include_once("detail-list-function.php"); 
?>
  



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include_once(ROOT_PATH_.'/controlbase/modules/head.php'); ?>
</head>

<body>
 



 
<?php


$new_detail_name           = addslashes($_REQUEST['name']);
$new_detail_borrowdate     = addslashes($_REQUEST['borrowdate']);
$new_detail_borrower       = addslashes($_REQUEST['borrower']);
$new_detail_status         = "借出";
$new_detail_remark         = addslashes($_REQUEST['remark']);

$new_detail_equipmentid         = addslashes($_REQUEST['equipmentid']);

   



//先检查一下车辆的状态，如果是已经借出，就不要再借了。


$equipment=select_one_line_all_items($table_Prefix."equipment","nid = '".$new_detail_equipmentid."'");



if($equipment['status']!="正常")
{
?>
<script type="text/javascript">
    alert("设备状态异常，请检查再借出.");
   document.location.href = "../equipment/detail-list.php?nav-itemed=equipment";
</script>

<?

}

else{




//设置需要搜索的表格的前缀后缀
$table_Suffix = "rental";
$table = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀
 
 

$sql = "INSERT INTO $table (
name,
borrowdate,
borrower,
status,
equipmentid,
remark
)

value (
'$new_detail_name',
'$new_detail_borrowdate',
'$new_detail_borrower',
'$new_detail_status',
'$new_detail_equipmentid',
'$new_detail_remark'
)";


$query = mysql_query($sql) or die ('添加数据失败！！');







//更新设备表的状态
//设置需要搜索的表格的前缀后缀
$table_Suffix = "equipment";
$table = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀



$sql = "update $table SET
status= '借出'
where nid=$new_detail_equipmentid";


$query = mysql_query($sql) or die ('添加数据失败！！');





mysql_close($con);

}
?>





<script type="text/javascript">
   alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "detail-list.php?nav-itemed=equipment";
</script>
</body>